﻿using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using BabyCloudDrives.DesktopApp.ViewModels;
using UserControl = System.Windows.Controls.UserControl;

namespace BabyCloudDrives.DesktopApp.Controls
{
    /// <summary>
    /// SkyDrive.xaml 的交互逻辑
    /// </summary>
    public partial class SkyDrive : UserControl
    {
        public SkyDrive()
        {
            InitializeComponent();
        }

        private void DownloadClick(object sender, RoutedEventArgs e)
        {
            var userControl = FindName("SkyDriveUC") as UserControl;
            var folderBrowserDialog = new FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() != DialogResult.OK || userControl == null)
            {
                e.Handled = true;
                return;
            }
            var vm = userControl.DataContext as SkyDriveViewModel;
            if (vm != null) vm.DownloadPath = folderBrowserDialog.SelectedPath;
        }
    }
}